//
//  CollectionViewCell.m
//  OAProject
//
//  Created by yhj on 2017/3/22.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "CollectionViewCell.h"
#import "YHJButton.h"

@interface CollectionViewCell ()

@property(nonatomic,strong)UIImageView *headUrl;

@property(nonatomic,strong)YHJButton *fileBtn;

@property(nonatomic,strong)UIButton *deleteBtn;

@end

@implementation CollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {

        //self.backgroundColor=[UIColor redColor];

        self.fileBtn.hidden=NO;

        self.deleteBtn.hidden=NO;

    }
    return self;
}

-(YHJButton *)fileBtn
{
    if (!_fileBtn) {
        _fileBtn=[YHJButton new];
        [self.contentView addSubview:self.fileBtn];
        _fileBtn.frame=CGRectMake(0,0,APPW/5,APPW/5+kmargin*2);
        [_fileBtn setTitle:@"文件" forState:0];
        [_fileBtn setImage:[UIImage imageNamed:@"default_File"] forState:0];
        [_fileBtn setImage:[UIImage imageNamed:@"default_File"] forState:1];
        [_fileBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
        [_fileBtn setImage:CGRectMake(0,kmargin/2,APPW/5,APPW/5) title:CGRectMake((APPW/5-40)/2,APPW/5+kmargin/2,40,20)];
        _fileBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
        [_fileBtn setTitleColor:LightGreyColor forState:0];
        _fileBtn.titleLabel.font=Font_Number(14);
        [_fileBtn addTarget:self action:@selector(fileBtnEvent:) forControlEvents:UIControlEventTouchUpInside];

    }
    return _fileBtn;
}

-(UIButton *)deleteBtn
{
    if (!_deleteBtn) {
        _deleteBtn=[AppUI createButtonWithSupeView:self andWithNormalImage:[UIImage imageNamed:@"delete_file"] andWithSelectImage:[UIImage imageNamed:@"delete_file"] andWithBtnAction:^{

            if (self.delegate&&[self.delegate respondsToSelector:@selector(deleteCollectionViewCell:index:)])
            {
                [self.delegate deleteCollectionViewCell:self index:23];
            }

        }];
        _deleteBtn.frame=CGRectMake(APPW/5-kmargin*3/2,kmargin/2,kmargin*3/2,kmargin*3/2);

      //  [_deleteBtn addTarget:self action:@selector(deleteBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.deleteBtn];
    }
    return _deleteBtn;
}

//-(void)deleteBtnEvent:(UIButton *)sender
//{
 //  }

-(void)fileBtnEvent:(YHJButton *)sender
{

}

@end
